package ynu.edu.Util;

import jakarta.annotation.Resource;
import org.antlr.v4.runtime.Token;
import org.springframework.boot.CommandLineRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import ynu.edu.Service.Impl.*;

import java.util.ArrayList;
import java.util.List;

@Component
public class StartFetch implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
//        System.out.println("");
//        System.out.println("传感器数据每10分钟获取一次");
//        System.out.println("摄像头抓拍每10分钟获取一次");
    }
    @Resource
    SensorUtil sensorUtil;
    @Resource
    WaterService waterService;
    @Resource
    TemperatureService temperatureService;
    @Resource
    NitrogenService nitrogenService;
    @Resource
    LightService lightService;
    @Resource
    CarbonService carbonService;
    @Resource
    CameraCaptureUtil cameraCaptureUtil;

//    @Scheduled(fixedRate = 600000)
//    private void startFetchSensor(){
//        String boxNo = "300023040198";
//        List<String> sensorIds = new ArrayList<>();
//        sensorIds.add("327061430532576246");
//        sensorIds.add("327061430532576250");
//        sensorIds.add("327061430532576242");
//        sensorIds.add("327061430532576249");
//        sensorIds.add("327061430532576245");
//        List<Double> sensorData = sensorUtil.fetchSensorData(boxNo, sensorIds);
//        waterService.insert(sensorData.get(0));
//        temperatureService.insert(sensorData.get(1));
//        nitrogenService.insert(sensorData.get(2));
//        lightService.insert(sensorData.get(3));
//        carbonService.insert(sensorData.get(4));
//    }
//    @Scheduled(fixedRate = 3600000)
//    public void startFetchCamera(){
//        String deviceSerial = "AB9831218";
//        int channelNo = 1;
//        int quality = 3;
//        cameraCaptureUtil.captureImage(deviceSerial, channelNo, quality);
//    }
}
